<?php function writable($path){
	$ret=false;
	$fp=fopen($path."/testifwritable.tst","w");
	$ret=!($fp===false);
	fclose($fp);
	unlink($path."/testifwritable.tst");
	return $ret;
}
require_once("admin-header.php");
if (!(isset($_SESSION['administrator']))){
	echo "<a href='../loginpage.php'>Please Login First!</a>";
	exit(1);
}
   $maxfile=min(ini_get("upload_max_filesize"),ini_get("post_max_size"));

?>
<?php 
    $show_form=true;
   if(!isset($OJ_SAE)||!$OJ_SAE){
	   if(!writable($OJ_DATA)){
		   echo " You need to add  $OJ_DATA into your open_basedir setting of php.ini,<br>
					or you need to execute:<br>
					   <b>chmod 775 -R $OJ_DATA && chgrp -R www-data $OJ_DATA</b><br>
					you can't use import function at this time.<br>"; 
			$show_form=false;
	   }
	   if(!writable("../upload")){
		   echo "../upload is not writable, <b>chmod 770</b> to it.<br>";
		   $show_form=false;
	   }
	}	
	if($show_form){
?>
<br>

<center><h2>题目导入（实验性）</h2></center>
<div class="alert alert-danger">双题库开发中，请勿使用。请上传FPS格式的XML文件！</div>

<form enctype="multipart/form-data" class="form-horizontal col-sm-6 col-sm-offset-2" action="problem_import_xml.php" method="post">
	<div class="form-group">
        
        <div class="col-sm-12">
        <input class="form-control" name="fps" type="file"/></div>
    </div>
	<?php require_once("../include/set_post_key.php");?>
	<div class="form-group">
        <div class="col-sm-offset-5 col-sm-7">
            <input type="submit" class="btn btn-primary col-sm-8" value="导入"/>
        </div>
    </div>
</form>



<?php 
  
   	}
   
?>

